import requests

# r = requests.get("https://www.baidu.com/")
#
# r.encoding = "utf-8"
# 打印响应文本
# print(r.text)
# 打印响应头
# print(r.headers)
# 打印响应状态码
# print(r.status_code)
# 打印编码格式
# print(r.encoding)
# 遍历响应头
# for i in r.headers.items():
#     print(i)

# print(r.headers["connection"])

r = requests.get("http://192.168.41.120:9999/news_list?cid=3&page=2")
news = r.json()["data"]["news_dict_li"]
# for i in news:
#     print(i)
print(len(news))
print(news[0])


# 获取文件
# r = requests.get("https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png")
# print(r.content)
# with open("a.png", "wb") as f:
#     f.write(r.content)


# 超时
# r = requests.get("https://www.baidu.com/", timeout=0.1)
# print(r.text)
